<?

/*
*
*   Excalibur Content Management System
*   Copyright © 2008 Egor 'Sontan' Kuryanovich
*
*   Based on Explay Engine v2.0 by Golovdinov Alexander
*
*   Official site: www.excms.ru
*   Contact e-mail: support@excms.ru
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
*/

if (!defined('DB_PEREFIX')) exit;

// Если контент скэширован и не устарел то отдаем его из кэша
if (is_cached ('excl_system_menu.php', 3600)) 
	$content = get_cached('excl_system_menu.php');
else 
{
	// Строим контент
	$content = build_system_menu ();
	// Кэшируем его
	cache_file ('excl_system_menu.php', $content);
}
$CORE->global_template_html = str_replace ($replace, $content, $CORE->global_template_html);


function build_system_menu()
{
	global $db;
	$get_menu = $db->query ('SELECT link_group, link_text, link_url, link_target FROM '.DB_PEREFIX.'_menu ORDER BY link_pos');

	$registered = 	is_registered();
	$return = '';	
	
	while (list($group, $text, $link, $target) = $db->fetch_row ($get_menu)) 
	{
		if ($registered || $group != 'register') 
		{	
			$menu = get_element('{menu}', '{/menu}');
			$menu = str_replace ('{LINK}', $link, $menu);
			$menu = str_replace ('{TARGET}', $target, $menu);
			$menu = str_replace ('{TEXT}', $text, $menu);
			$return .= $menu;
		}
	}
	
	return $return;
}


